class websocket {
	constructor(url, callBack) {
		this.is_open_socket = false; //是否已链接
		this.url = url; //websocket地址
		this.data = null;
		//心跳检测
		this.heartbeatInterval = null;
		this.reconnectInterval = null;
		this.isClose = false; //是否手动关闭
		this.callBack = callBack;
		this.requestNum = 1;
		
		// 测试页面监听消息-测试
		// this.messageObj = {a:1};
		// setInterval(res=>{
		// 	this.messageObj.a = this.messageObj.a+1;
		// 	let obj = JSON.parse(JSON.stringify(this.messageObj))
		// 	callBack(obj);
		// },2000);
		// return;
		try {
			return this.connectSocketInit();
		} catch (e) {
			// console.log('catch', '未开始链接');
			this.is_open_socket = false;
			this.reconnect();
		}
	}
	// 创建websocket连接
	connectSocketInit() {
		if (this.is_open_socket) {
			return
		};
		this.socketTask = uni.connectSocket({
			url: this.url,
			header: {
				'Sec-Websocket-Protocol': uni.getStorageSync('token')
			},
			success: () => {
				// console.log("正准备建立websocket中...");
				// 返回实例
				return this.socketTask
			},
			fail: (err) => {
				// console.log("建立websocket失败...", err);
			}
		});
		this.socketTask.onOpen((res) => {
			console.log("WebSocket连接正常！");
			let obj = {
				"takerBuySellVolume_ETH1w": [{
						"buyRatio": 50.11,
						"exchange": "Binance",
						"sellRatio": 42.33
					},
					{
						"buyRatio": 48.3,
						"exchange": "OKX",
						"sellRatio": 51.7
					},
					{
						"buyRatio": 49.04,
						"exchange": "dYdX",
						"sellRatio": 50.96
					},
					{
						"buyRatio": 49.98,
						"exchange": "Crypto.com",
						"sellRatio": 50.02
					},
					{
						"buyRatio": 41.83,
						"exchange": "BingX",
						"sellRatio": 58.17
					},
					{
						"buyRatio": 48.99,
						"exchange": "Bitget",
						"sellRatio": 51.01
					},
					{
						"buyRatio": 44.43,
						"exchange": "Deribit",
						"sellRatio": 55.57
					},
					{
						"buyRatio": 50.88,
						"exchange": "Bybit",
						"sellRatio": 49.12
					},
					{
						"buyRatio": 54.35,
						"exchange": "Bitmex",
						"sellRatio": 45.65
					},
					{
						"buyRatio": 45.94,
						"exchange": "Bitfinex",
						"sellRatio": 54.06
					},
					{
						"buyRatio": 51.41,
						"exchange": "CoinEx",
						"sellRatio": 48.59
					},
					{
						"buyRatio": 51.47,
						"exchange": "Kraken",
						"sellRatio": 48.53
					},
					{
						"buyRatio": 50.23,
						"exchange": "HTX",
						"sellRatio": 49.77
					},
					{
						"buyRatio": 50.03,
						"exchange": "Coinbase",
						"sellRatio": 49.97
					}
				],
				"takerBuySellVolume_ETH12h": [{
						"buyRatio": 50.48,
						"exchange": "Binance",
						"sellRatio": 49.52
					},
					{
						"buyRatio": 48.07,
						"exchange": "OKX",
						"sellRatio": 51.93
					},
					{
						"buyRatio": 43.09,
						"exchange": "dYdX",
						"sellRatio": 56.91
					},
					{
						"buyRatio": 50.08,
						"exchange": "Crypto.com",
						"sellRatio": 49.92
					},
					{
						"buyRatio": 35.87,
						"exchange": "BingX",
						"sellRatio": 64.13
					},
					{
						"buyRatio": 48.6,
						"exchange": "Bitget",
						"sellRatio": 51.4
					},
					{
						"buyRatio": 49.55,
						"exchange": "Deribit",
						"sellRatio": 50.45
					},
					{
						"buyRatio": 52.66,
						"exchange": "Bybit",
						"sellRatio": 47.34
					},
					{
						"buyRatio": 60.32,
						"exchange": "Bitmex",
						"sellRatio": 39.68
					},
					{
						"buyRatio": 56.97,
						"exchange": "Bitfinex",
						"sellRatio": 43.03
					},
					{
						"buyRatio": 52.76,
						"exchange": "CoinEx",
						"sellRatio": 47.24
					},
					{
						"buyRatio": 59.9,
						"exchange": "Kraken",
						"sellRatio": 40.1
					},
					{
						"buyRatio": 50.19,
						"exchange": "HTX",
						"sellRatio": 49.81
					},
					{
						"buyRatio": 50.03,
						"exchange": "Coinbase",
						"sellRatio": 49.97
					}
				],
				"BTC_USDT_PRICE": {
					"exName": "Binance",
					"price": "60727.06000000",
					"priceChangePercent24h": "0.4300",
					"symbol": "BTC/USDT",
					"volUsd24h": "1320704089.7949"
				},
				"takerBuySellVolume_ETH24h": [{
						"buyRatio": 50.1,
						"exchange": "Binance",
						"sellRatio": 49.9
					},
					{
						"buyRatio": 48.3,
						"exchange": "OKX",
						"sellRatio": 51.7
					},
					{
						"buyRatio": 49.03,
						"exchange": "dYdX",
						"sellRatio": 50.97
					},
					{
						"buyRatio": 49.98,
						"exchange": "Crypto.com",
						"sellRatio": 50.02
					},
					{
						"buyRatio": 41.83,
						"exchange": "BingX",
						"sellRatio": 58.17
					},
					{
						"buyRatio": 48.99,
						"exchange": "Bitget",
						"sellRatio": 51.01
					},
					{
						"buyRatio": 44.42,
						"exchange": "Deribit",
						"sellRatio": 55.58
					},
					{
						"buyRatio": 50.87,
						"exchange": "Bybit",
						"sellRatio": 49.13
					},
					{
						"buyRatio": 54.35,
						"exchange": "Bitmex",
						"sellRatio": 45.65
					},
					{
						"buyRatio": 45.94,
						"exchange": "Bitfinex",
						"sellRatio": 54.06
					},
					{
						"buyRatio": 51.41,
						"exchange": "CoinEx",
						"sellRatio": 48.59
					},
					{
						"buyRatio": 51.48,
						"exchange": "Kraken",
						"sellRatio": 48.52
					},
					{
						"buyRatio": 50.22,
						"exchange": "HTX",
						"sellRatio": 49.78
					},
					{
						"buyRatio": 50.03,
						"exchange": "Coinbase",
						"sellRatio": 49.97
					}
				],
				"takerBuySellVolume_ETH30m": [{
						"buyRatio": 40.74,
						"exchange": "Binance",
						"sellRatio": 59.26
					},
					{
						"buyRatio": 40.84,
						"exchange": "OKX",
						"sellRatio": 59.16
					},
					{
						"buyRatio": 10.87,
						"exchange": "dYdX",
						"sellRatio": 89.13
					},
					{
						"buyRatio": 49.44,
						"exchange": "Crypto.com",
						"sellRatio": 50.56
					},
					{
						"buyRatio": 36.04,
						"exchange": "BingX",
						"sellRatio": 63.96
					},
					{
						"buyRatio": 45.19,
						"exchange": "Bitget",
						"sellRatio": 54.81
					},
					{
						"buyRatio": 34.79,
						"exchange": "Deribit",
						"sellRatio": 65.21
					},
					{
						"buyRatio": 50.45,
						"exchange": "Bybit",
						"sellRatio": 49.55
					},
					{
						"buyRatio": 8.75,
						"exchange": "Bitmex",
						"sellRatio": 91.25
					},
					{
						"buyRatio": 52.79,
						"exchange": "Bitfinex",
						"sellRatio": 47.21
					},
					{
						"buyRatio": 25.93,
						"exchange": "CoinEx",
						"sellRatio": 74.07
					},
					{
						"buyRatio": 45.13,
						"exchange": "Kraken",
						"sellRatio": 54.87
					},
					{
						"buyRatio": 45.99,
						"exchange": "HTX",
						"sellRatio": 54.01
					},
					{
						"buyRatio": 48.72,
						"exchange": "Coinbase",
						"sellRatio": 51.28
					}
				],
				"takerBuySellVolume_BTC_1w": [{
						"buyRatio": 50.31,
						"exchange": "Binance",
						"sellRatio": 42.33
					},
					{
						"buyRatio": 49.13,
						"exchange": "OKX",
						"sellRatio": 50.87
					},
					{
						"buyRatio": 42.85,
						"exchange": "dYdX",
						"sellRatio": 57.15
					},
					{
						"buyRatio": 49.81,
						"exchange": "Crypto.com",
						"sellRatio": 50.19
					},
					{
						"buyRatio": 40.38,
						"exchange": "BingX",
						"sellRatio": 59.62
					},
					{
						"buyRatio": 50.87,
						"exchange": "Bitget",
						"sellRatio": 49.13
					},
					{
						"buyRatio": 49.06,
						"exchange": "Deribit",
						"sellRatio": 50.94
					},
					{
						"buyRatio": 49.56,
						"exchange": "Bybit",
						"sellRatio": 50.44
					},
					{
						"buyRatio": 54.67,
						"exchange": "Bitmex",
						"sellRatio": 45.33
					},
					{
						"buyRatio": 44.46,
						"exchange": "Bitfinex",
						"sellRatio": 55.54
					},
					{
						"buyRatio": 48.86,
						"exchange": "CoinEx",
						"sellRatio": 51.14
					},
					{
						"buyRatio": 48.57,
						"exchange": "Kraken",
						"sellRatio": 51.43
					},
					{
						"buyRatio": 49.86,
						"exchange": "HTX",
						"sellRatio": 50.14
					},
					{
						"buyRatio": 49.93,
						"exchange": "Coinbase",
						"sellRatio": 50.07
					}
				],
				"takerBuySellVolume_ETH4h": [{
						"buyRatio": 49.03,
						"exchange": "Binance",
						"sellRatio": 50.97
					},
					{
						"buyRatio": 46.1,
						"exchange": "OKX",
						"sellRatio": 53.9
					},
					{
						"buyRatio": 46.71,
						"exchange": "dYdX",
						"sellRatio": 53.29
					},
					{
						"buyRatio": 49.74,
						"exchange": "Crypto.com",
						"sellRatio": 50.26
					},
					{
						"buyRatio": 34.65,
						"exchange": "BingX",
						"sellRatio": 65.35
					},
					{
						"buyRatio": 50.46,
						"exchange": "Bitget",
						"sellRatio": 49.54
					},
					{
						"buyRatio": 57.41,
						"exchange": "Deribit",
						"sellRatio": 42.59
					},
					{
						"buyRatio": 52.98,
						"exchange": "Bybit",
						"sellRatio": 47.02
					},
					{
						"buyRatio": 63.59,
						"exchange": "Bitmex",
						"sellRatio": 36.41
					},
					{
						"buyRatio": 50.22,
						"exchange": "Bitfinex",
						"sellRatio": 49.78
					},
					{
						"buyRatio": 54.53,
						"exchange": "CoinEx",
						"sellRatio": 45.47
					},
					{
						"buyRatio": 57.81,
						"exchange": "Kraken",
						"sellRatio": 42.19
					},
					{
						"buyRatio": 51.24,
						"exchange": "HTX",
						"sellRatio": 48.76
					},
					{
						"buyRatio": 49.89,
						"exchange": "Coinbase",
						"sellRatio": 50.11
					}
				],
				"takerBuySellVolume_BTC_12h": [{
						"buyRatio": 48.66,
						"exchange": "Binance",
						"sellRatio": 51.34
					},
					{
						"buyRatio": 48.49,
						"exchange": "OKX",
						"sellRatio": 51.51
					},
					{
						"buyRatio": 36.51,
						"exchange": "dYdX",
						"sellRatio": 63.49
					},
					{
						"buyRatio": 49.56,
						"exchange": "Crypto.com",
						"sellRatio": 50.44
					},
					{
						"buyRatio": 35.85,
						"exchange": "BingX",
						"sellRatio": 64.15
					},
					{
						"buyRatio": 51.39,
						"exchange": "Bitget",
						"sellRatio": 48.61
					},
					{
						"buyRatio": 57.16,
						"exchange": "Deribit",
						"sellRatio": 42.84
					},
					{
						"buyRatio": 47.66,
						"exchange": "Bybit",
						"sellRatio": 52.34
					},
					{
						"buyRatio": 60.12,
						"exchange": "Bitmex",
						"sellRatio": 39.88
					},
					{
						"buyRatio": 48.62,
						"exchange": "Bitfinex",
						"sellRatio": 51.38
					},
					{
						"buyRatio": 48.09,
						"exchange": "CoinEx",
						"sellRatio": 51.91
					},
					{
						"buyRatio": 44.12,
						"exchange": "Kraken",
						"sellRatio": 55.88
					},
					{
						"buyRatio": 49.9,
						"exchange": "HTX",
						"sellRatio": 50.1
					},
					{
						"buyRatio": 49.67,
						"exchange": "Coinbase",
						"sellRatio": 50.33
					}
				],
				"takerBuySellVolume_BTC_24h": [{
						"buyRatio": 50.31,
						"exchange": "Binance",
						"sellRatio": 49.69
					},
					{
						"buyRatio": 49.12,
						"exchange": "OKX",
						"sellRatio": 50.88
					},
					{
						"buyRatio": 42.85,
						"exchange": "dYdX",
						"sellRatio": 57.15
					},
					{
						"buyRatio": 49.81,
						"exchange": "Crypto.com",
						"sellRatio": 50.19
					},
					{
						"buyRatio": 40.38,
						"exchange": "BingX",
						"sellRatio": 59.62
					},
					{
						"buyRatio": 50.87,
						"exchange": "Bitget",
						"sellRatio": 49.13
					},
					{
						"buyRatio": 49.06,
						"exchange": "Deribit",
						"sellRatio": 50.94
					},
					{
						"buyRatio": 49.55,
						"exchange": "Bybit",
						"sellRatio": 50.45
					},
					{
						"buyRatio": 54.67,
						"exchange": "Bitmex",
						"sellRatio": 45.33
					},
					{
						"buyRatio": 44.46,
						"exchange": "Bitfinex",
						"sellRatio": 55.54
					},
					{
						"buyRatio": 48.86,
						"exchange": "CoinEx",
						"sellRatio": 51.14
					},
					{
						"buyRatio": 48.57,
						"exchange": "Kraken",
						"sellRatio": 51.43
					},
					{
						"buyRatio": 49.86,
						"exchange": "HTX",
						"sellRatio": 50.14
					},
					{
						"buyRatio": 49.93,
						"exchange": "Coinbase",
						"sellRatio": 50.07
					}
				],
				"optionsMarkets_ETH_1h": {
					"buyRatio": 43.19,
					"buyTimeEnd": "20:20",
					"buyTimeStart": "20:00",
					"coinType": "ETH",
					"price": "60727.06000000",
					"priceChangePercent": "0.4300",
					"range": "1h",
					"sellLossPercent": "20%",
					"sellProfitPercent": "10%",
					"sellRatio": 56.81,
					"sellTimeEnd": "20:40",
					"sellTimeStart": "20:20",
					"settlementLossPercent": "100%",
					"settlementProfitPercent": "70%",
					"settlementTimeEnd": "20:59:59",
					"settlementTimeStart": "20:40"
				},
				"takerBuySellVolume_BTC_8h": [{
						"buyRatio": 48.61,
						"exchange": "Binance",
						"sellRatio": 42.33
					},
					{
						"buyRatio": 48.35,
						"exchange": "OKX",
						"sellRatio": 51.65
					},
					{
						"buyRatio": 36.42,
						"exchange": "dYdX",
						"sellRatio": 63.58
					},
					{
						"buyRatio": 49.57,
						"exchange": "Crypto.com",
						"sellRatio": 50.43
					},
					{
						"buyRatio": 35.83,
						"exchange": "BingX",
						"sellRatio": 64.17
					},
					{
						"buyRatio": 51.34,
						"exchange": "Bitget",
						"sellRatio": 48.66
					},
					{
						"buyRatio": 57.31,
						"exchange": "Deribit",
						"sellRatio": 42.69
					},
					{
						"buyRatio": 47.61,
						"exchange": "Bybit",
						"sellRatio": 52.39
					},
					{
						"buyRatio": 59.99,
						"exchange": "Bitmex",
						"sellRatio": 40.01
					},
					{
						"buyRatio": 48.44,
						"exchange": "Bitfinex",
						"sellRatio": 51.56
					},
					{
						"buyRatio": 48.09,
						"exchange": "CoinEx",
						"sellRatio": 51.91
					},
					{
						"buyRatio": 44.02,
						"exchange": "Kraken",
						"sellRatio": 55.98
					},
					{
						"buyRatio": 49.87,
						"exchange": "HTX",
						"sellRatio": 50.13
					},
					{
						"buyRatio": 49.63,
						"exchange": "Coinbase",
						"sellRatio": 50.37
					}
				],
				"takerBuySellVolume_ETH8h": [{
						"buyRatio": 50.49,
						"exchange": "Binance",
						"sellRatio": 42.33
					},
					{
						"buyRatio": 48.06,
						"exchange": "OKX",
						"sellRatio": 51.94
					},
					{
						"buyRatio": 43.16,
						"exchange": "dYdX",
						"sellRatio": 56.84
					},
					{
						"buyRatio": 50.1,
						"exchange": "Crypto.com",
						"sellRatio": 49.9
					},
					{
						"buyRatio": 35.86,
						"exchange": "BingX",
						"sellRatio": 64.14
					},
					{
						"buyRatio": 48.59,
						"exchange": "Bitget",
						"sellRatio": 51.41
					},
					{
						"buyRatio": 49.51,
						"exchange": "Deribit",
						"sellRatio": 50.49
					},
					{
						"buyRatio": 52.67,
						"exchange": "Bybit",
						"sellRatio": 47.33
					},
					{
						"buyRatio": 60.31,
						"exchange": "Bitmex",
						"sellRatio": 39.69
					},
					{
						"buyRatio": 56.96,
						"exchange": "Bitfinex",
						"sellRatio": 43.04
					},
					{
						"buyRatio": 52.76,
						"exchange": "CoinEx",
						"sellRatio": 47.24
					},
					{
						"buyRatio": 59.94,
						"exchange": "Kraken",
						"sellRatio": 40.06
					},
					{
						"buyRatio": 50.2,
						"exchange": "HTX",
						"sellRatio": 49.8
					},
					{
						"buyRatio": 50.02,
						"exchange": "Coinbase",
						"sellRatio": 49.98
					}
				],
				"optionsMarkets_BTC_15m": {
					"buyRatio": 35.62,
					"buyTimeEnd": "20:50",
					"buyTimeStart": "20:45",
					"coinType": "BTC",
					"price": "60727.06000000",
					"priceChangePercent": "0.4300",
					"range": "15m",
					"sellLossPercent": "60%",
					"sellProfitPercent": "30%",
					"sellRatio": 64.38,
					"sellTimeEnd": "20:55",
					"sellTimeStart": "20:50",
					"settlementLossPercent": "100%",
					"settlementProfitPercent": "80%",
					"settlementTimeEnd": "20:59:59",
					"settlementTimeStart": "20:55"
				},
				"takerBuySellVolume_BTC_30m": [{
						"buyRatio": 35.66,
						"exchange": "Binance",
						"sellRatio": 64.34
					},
					{
						"buyRatio": 37.64,
						"exchange": "OKX",
						"sellRatio": 62.36
					},
					{
						"buyRatio": 20.28,
						"exchange": "dYdX",
						"sellRatio": 79.72
					},
					{
						"buyRatio": 48.56,
						"exchange": "Crypto.com",
						"sellRatio": 51.44
					},
					{
						"buyRatio": 32.82,
						"exchange": "BingX",
						"sellRatio": 67.18
					},
					{
						"buyRatio": 46.07,
						"exchange": "Bitget",
						"sellRatio": 53.93
					},
					{
						"buyRatio": 43.01,
						"exchange": "Deribit",
						"sellRatio": 56.99
					},
					{
						"buyRatio": 41.68,
						"exchange": "Bybit",
						"sellRatio": 58.32
					},
					{
						"buyRatio": 45.09,
						"exchange": "Bitmex",
						"sellRatio": 54.91
					},
					{
						"buyRatio": 40.45,
						"exchange": "Bitfinex",
						"sellRatio": 59.55
					},
					{
						"buyRatio": 40.7,
						"exchange": "CoinEx",
						"sellRatio": 59.3
					},
					{
						"buyRatio": 17.03,
						"exchange": "Kraken",
						"sellRatio": 82.97
					},
					{
						"buyRatio": 38.32,
						"exchange": "HTX",
						"sellRatio": 61.68
					},
					{
						"buyRatio": 48.16,
						"exchange": "Coinbase",
						"sellRatio": 51.84
					}
				],
				"takerBuySellVolume_BTC_4h": [{
						"buyRatio": 46.39,
						"exchange": "Binance",
						"sellRatio": 53.61
					},
					{
						"buyRatio": 47.24,
						"exchange": "OKX",
						"sellRatio": 52.76
					},
					{
						"buyRatio": 36.24,
						"exchange": "dYdX",
						"sellRatio": 63.76
					},
					{
						"buyRatio": 49.44,
						"exchange": "Crypto.com",
						"sellRatio": 50.56
					},
					{
						"buyRatio": 36.91,
						"exchange": "BingX",
						"sellRatio": 63.09
					},
					{
						"buyRatio": 50.81,
						"exchange": "Bitget",
						"sellRatio": 49.19
					},
					{
						"buyRatio": 54.19,
						"exchange": "Deribit",
						"sellRatio": 45.81
					},
					{
						"buyRatio": 47.25,
						"exchange": "Bybit",
						"sellRatio": 52.75
					},
					{
						"buyRatio": 56.39,
						"exchange": "Bitmex",
						"sellRatio": 43.61
					},
					{
						"buyRatio": 54.45,
						"exchange": "Bitfinex",
						"sellRatio": 45.55
					},
					{
						"buyRatio": 47.08,
						"exchange": "CoinEx",
						"sellRatio": 52.92
					},
					{
						"buyRatio": 45.12,
						"exchange": "Kraken",
						"sellRatio": 54.88
					},
					{
						"buyRatio": 50.13,
						"exchange": "HTX",
						"sellRatio": 49.87
					},
					{
						"buyRatio": 49.87,
						"exchange": "Coinbase",
						"sellRatio": 50.13
					}
				],
				"optionsMarkets_BTC_1h": {
					"buyRatio": 42.16,
					"buyTimeEnd": "20:20",
					"buyTimeStart": "20:00",
					"coinType": "BTC",
					"price": "60727.06000000",
					"priceChangePercent": "0.4300",
					"range": "1h",
					"sellLossPercent": "20%",
					"sellProfitPercent": "10%",
					"sellRatio": 57.84,
					"sellTimeEnd": "20:40",
					"sellTimeStart": "20:20",
					"settlementLossPercent": "100%",
					"settlementProfitPercent": "70%",
					"settlementTimeEnd": "20:59:59",
					"settlementTimeStart": "20:40"
				},
				"optionsMarkets_ETH_15m": {
					"buyRatio": 41.39,
					"buyTimeEnd": "20:50",
					"buyTimeStart": "20:45",
					"coinType": "ETH",
					"price": "60727.06000000",
					"priceChangePercent": "0.4300",
					"range": "15m",
					"sellLossPercent": "60%",
					"sellProfitPercent": "30%",
					"sellRatio": 58.61,
					"sellTimeEnd": "20:55",
					"sellTimeStart": "20:50",
					"settlementLossPercent": "100%",
					"settlementProfitPercent": "80%",
					"settlementTimeEnd": "20:59:59",
					"settlementTimeStart": "20:55"
				},
				"takerBuySellVolume_ETH15m": [{
						"buyRatio": 38.77,
						"exchange": "Binance",
						"sellRatio": 61.23
					},
					{
						"buyRatio": 40.52,
						"exchange": "OKX",
						"sellRatio": 59.48
					},
					{
						"buyRatio": 9.55,
						"exchange": "dYdX",
						"sellRatio": 90.45
					},
					{
						"buyRatio": 49.06,
						"exchange": "Crypto.com",
						"sellRatio": 50.94
					},
					{
						"buyRatio": 33.31,
						"exchange": "BingX",
						"sellRatio": 66.69
					},
					{
						"buyRatio": 45.21,
						"exchange": "Bitget",
						"sellRatio": 54.79
					},
					{
						"buyRatio": 8.51,
						"exchange": "Deribit",
						"sellRatio": 91.49
					},
					{
						"buyRatio": 45.39,
						"exchange": "Bybit",
						"sellRatio": 54.61
					},
					{
						"buyRatio": 4.78,
						"exchange": "Bitmex",
						"sellRatio": 95.22
					},
					{
						"buyRatio": 94.8,
						"exchange": "Bitfinex",
						"sellRatio": 5.2
					},
					{
						"buyRatio": 34.02,
						"exchange": "CoinEx",
						"sellRatio": 65.98
					},
					{
						"buyRatio": 34.13,
						"exchange": "Kraken",
						"sellRatio": 65.87
					},
					{
						"buyRatio": 49.71,
						"exchange": "HTX",
						"sellRatio": 50.29
					},
					{
						"buyRatio": 47.49,
						"exchange": "Coinbase",
						"sellRatio": 52.51
					}
				],
				"takerBuySellVolume_BTC_15m": [{
						"buyRatio": 29.88,
						"exchange": "Binance",
						"sellRatio": 70.12
					},
					{
						"buyRatio": 28.44,
						"exchange": "OKX",
						"sellRatio": 71.56
					},
					{
						"buyRatio": 16.86,
						"exchange": "dYdX",
						"sellRatio": 83.14
					},
					{
						"buyRatio": 46.26,
						"exchange": "Crypto.com",
						"sellRatio": 53.74
					},
					{
						"buyRatio": 30.05,
						"exchange": "BingX",
						"sellRatio": 69.95
					},
					{
						"buyRatio": 46.35,
						"exchange": "Bitget",
						"sellRatio": 53.65
					},
					{
						"buyRatio": 36.67,
						"exchange": "Deribit",
						"sellRatio": 63.33
					},
					{
						"buyRatio": 34.4,
						"exchange": "Bybit",
						"sellRatio": 65.6
					},
					{
						"buyRatio": 44.39,
						"exchange": "Bitmex",
						"sellRatio": 55.61
					},
					{
						"buyRatio": 26.05,
						"exchange": "Bitfinex",
						"sellRatio": 73.95
					},
					{
						"buyRatio": 40.89,
						"exchange": "CoinEx",
						"sellRatio": 59.11
					},
					{
						"buyRatio": 17.25,
						"exchange": "Kraken",
						"sellRatio": 82.75
					},
					{
						"buyRatio": 29.85,
						"exchange": "HTX",
						"sellRatio": 70.15
					},
					{
						"buyRatio": 48.21,
						"exchange": "Coinbase",
						"sellRatio": 51.79
					}
				],
				"pairs_markets_BTC": [{
						"exName": "Binance",
						"price": "60727.06000000",
						"priceChangePercent24h": "0.4300",
						"symbol": "BTC/USDT",
						"volUsd24h": "1320704089.7949"
					},
					{
						"exName": "OKX",
						"price": "60723.3",
						"priceChangePercent24h": "0.4100",
						"symbol": "BTC/USDT",
						"volUsd24h": "439190394.4539"
					},
					{
						"exName": "Bybit",
						"price": "60734.19",
						"priceChangePercent24h": "0.4500",
						"symbol": "BTC/USDT",
						"volUsd24h": "1352696807.9264"
					},
					{
						"exName": "Coinbase",
						"price": "60742.38",
						"priceChangePercent24h": "0.4300",
						"symbol": "BTC/USD",
						"volUsd24h": "524663223.1836"
					},
					{
						"exName": "Coinbase",
						"price": "60743.21",
						"priceChangePercent24h": "0.5300",
						"symbol": "BTC/USDT",
						"volUsd24h": "33059556.8204"
					},
					{
						"exName": "Bitfinex",
						"price": "60850",
						"priceChangePercent24h": "0.4500",
						"symbol": "BTC/USD",
						"volUsd24h": "29430106.5899"
					},
					{
						"exName": "Kraken",
						"price": "60745.80000",
						"priceChangePercent24h": "0.4100",
						"symbol": "BTC/USD",
						"volUsd24h": "173537324.8195"
					},
					{
						"exName": "Kraken",
						"price": "60766.200000000000000",
						"priceChangePercent24h": "0.5100",
						"symbol": "BTC/USDT",
						"volUsd24h": "22510018.0294"
					},
					{
						"exName": "Bitstamp",
						"price": "60742",
						"priceChangePercent24h": "0.4100",
						"symbol": "BTC/USD",
						"volUsd24h": "110103150.3012"
					},
					{
						"exName": "Bitstamp",
						"price": "60748.000000000000000",
						"priceChangePercent24h": "0.4900",
						"symbol": "BTC/USDT",
						"volUsd24h": "689823.8750"
					}
				],
				"takerBuySellVolume_BTC_5m": [{
						"buyRatio": 48.25,
						"exchange": "Binance",
						"sellRatio": 51.75
					},
					{
						"buyRatio": 42.54,
						"exchange": "OKX",
						"sellRatio": 57.46
					},
					{
						"buyRatio": 100,
						"exchange": "dYdX",
						"sellRatio": 0
					},
					{
						"buyRatio": 51.21,
						"exchange": "Crypto.com",
						"sellRatio": 48.79
					},
					{
						"buyRatio": 38.78,
						"exchange": "BingX",
						"sellRatio": 61.22
					},
					{
						"buyRatio": 48.38,
						"exchange": "Bitget",
						"sellRatio": 51.62
					},
					{
						"buyRatio": 51.3,
						"exchange": "Deribit",
						"sellRatio": 48.7
					},
					{
						"buyRatio": 50.27,
						"exchange": "Bybit",
						"sellRatio": 49.73
					},
					{
						"buyRatio": 60.73,
						"exchange": "Bitmex",
						"sellRatio": 39.27
					},
					{
						"buyRatio": 11.06,
						"exchange": "Bitfinex",
						"sellRatio": 88.94
					},
					{
						"buyRatio": 41.23,
						"exchange": "CoinEx",
						"sellRatio": 58.77
					},
					{
						"buyRatio": 18.8,
						"exchange": "Kraken",
						"sellRatio": 81.2
					},
					{
						"buyRatio": 78.16,
						"exchange": "HTX",
						"sellRatio": 21.84
					},
					{
						"buyRatio": 51.2,
						"exchange": "Coinbase",
						"sellRatio": 48.8
					}
				],
				"takerBuySellVolume_ETH5m": [{
						"buyRatio": 45.67,
						"exchange": "Binance",
						"sellRatio": 54.33
					},
					{
						"buyRatio": 50.3,
						"exchange": "OKX",
						"sellRatio": 49.7
					},
					{
						"buyRatio": 6.43,
						"exchange": "dYdX",
						"sellRatio": 93.57
					},
					{
						"buyRatio": 50.84,
						"exchange": "Crypto.com",
						"sellRatio": 49.16
					},
					{
						"buyRatio": 33.22,
						"exchange": "BingX",
						"sellRatio": 66.78
					},
					{
						"buyRatio": 47.63,
						"exchange": "Bitget",
						"sellRatio": 52.37
					},
					{
						"buyRatio": 7.64,
						"exchange": "Deribit",
						"sellRatio": 92.36
					},
					{
						"buyRatio": 51.44,
						"exchange": "Bybit",
						"sellRatio": 48.56
					},
					{
						"buyRatio": 21.55,
						"exchange": "Bitmex",
						"sellRatio": 78.45
					},
					{
						"buyRatio": 91.13,
						"exchange": "Bitfinex",
						"sellRatio": 8.87
					},
					{
						"buyRatio": 54.14,
						"exchange": "CoinEx",
						"sellRatio": 45.86
					},
					{
						"buyRatio": 44,
						"exchange": "Kraken",
						"sellRatio": 56
					},
					{
						"buyRatio": 44.86,
						"exchange": "HTX",
						"sellRatio": 55.14
					},
					{
						"buyRatio": 51.85,
						"exchange": "Coinbase",
						"sellRatio": 48.15
					}
				],
				"takerBuySellVolume_ETH1h": [{
						"buyRatio": 40.55,
						"exchange": "Binance",
						"sellRatio": 59.45
					},
					{
						"buyRatio": 38.03,
						"exchange": "OKX",
						"sellRatio": 61.97
					},
					{
						"buyRatio": 22.69,
						"exchange": "dYdX",
						"sellRatio": 77.31
					},
					{
						"buyRatio": 49.23,
						"exchange": "Crypto.com",
						"sellRatio": 50.77
					},
					{
						"buyRatio": 34.36,
						"exchange": "BingX",
						"sellRatio": 65.64
					},
					{
						"buyRatio": 47.18,
						"exchange": "Bitget",
						"sellRatio": 52.82
					},
					{
						"buyRatio": 61.61,
						"exchange": "Deribit",
						"sellRatio": 38.39
					},
					{
						"buyRatio": 44.79,
						"exchange": "Bybit",
						"sellRatio": 55.21
					},
					{
						"buyRatio": 68.35,
						"exchange": "Bitmex",
						"sellRatio": 31.65
					},
					{
						"buyRatio": 50.23,
						"exchange": "Bitfinex",
						"sellRatio": 49.77
					},
					{
						"buyRatio": 39.03,
						"exchange": "CoinEx",
						"sellRatio": 60.97
					},
					{
						"buyRatio": 37.1,
						"exchange": "Kraken",
						"sellRatio": 62.9
					},
					{
						"buyRatio": 46.73,
						"exchange": "HTX",
						"sellRatio": 53.27
					},
					{
						"buyRatio": 49.49,
						"exchange": "Coinbase",
						"sellRatio": 50.51
					}
				],
				"optionsMarkets_BTC_30m": {
					"buyRatio": 39.87,
					"buyTimeEnd": "20:40",
					"buyTimeStart": "20:30",
					"coinType": "BTC",
					"price": "60727.06000000",
					"priceChangePercent": "0.4300",
					"range": "30m",
					"sellLossPercent": "40%",
					"sellProfitPercent": "20%",
					"sellRatio": 60.13,
					"sellTimeEnd": "20:50",
					"sellTimeStart": "20:40",
					"settlementLossPercent": "100%",
					"settlementProfitPercent": "75%",
					"settlementTimeEnd": "20:59:59",
					"settlementTimeStart": "20:50"
				},
				"pairs_markets_ETH": [{
						"exName": "Binance",
						"price": "2628.91000000",
						"priceChangePercent24h": "0.4300",
						"symbol": "ETH/USDT",
						"volUsd24h": "765550823.0329"
					},
					{
						"exName": "OKX",
						"price": "2628.89",
						"priceChangePercent24h": "0.4300",
						"symbol": "ETH/USDT",
						"volUsd24h": "262898252.2292"
					},
					{
						"exName": "Bybit",
						"price": "2629.26",
						"priceChangePercent24h": "0.4400",
						"symbol": "ETH/USDT",
						"volUsd24h": "336759738.3098"
					},
					{
						"exName": "Coinbase",
						"price": "2629.55",
						"priceChangePercent24h": "0.4100",
						"symbol": "ETH/USD",
						"volUsd24h": "199846560.8710"
					},
					{
						"exName": "Coinbase",
						"price": "2630.08",
						"priceChangePercent24h": "0.4700",
						"symbol": "ETH/USDT",
						"volUsd24h": "14356334.1014"
					},
					{
						"exName": "Bitfinex",
						"price": "2633.2",
						"priceChangePercent24h": "0.5200",
						"symbol": "ETH/USD",
						"volUsd24h": "7074841.7291"
					},
					{
						"exName": "Kraken",
						"price": "2631.22000",
						"priceChangePercent24h": "0.3700",
						"symbol": "ETH/USDT",
						"volUsd24h": "3032806.5975"
					},
					{
						"exName": "Kraken",
						"price": "2629.39000",
						"priceChangePercent24h": "0.4100",
						"symbol": "ETH/USD",
						"volUsd24h": "21598365.1108"
					},
					{
						"exName": "Bitstamp",
						"price": "2629.1",
						"priceChangePercent24h": "0.2800",
						"symbol": "ETH/USD",
						"volUsd24h": "7427450.1977"
					},
					{
						"exName": "Bitstamp",
						"price": "2630.100000000000000",
						"priceChangePercent24h": "0.0600",
						"symbol": "ETH/USDT",
						"volUsd24h": "252954.7000"
					}
				],
				"takerBuySellVolume_BTC_1h": [{
						"buyRatio": 39.87,
						"exchange": "Binance",
						"sellRatio": 60.13
					},
					{
						"buyRatio": 41.09,
						"exchange": "OKX",
						"sellRatio": 58.91
					},
					{
						"buyRatio": 23.93,
						"exchange": "dYdX",
						"sellRatio": 76.07
					},
					{
						"buyRatio": 49.35,
						"exchange": "Crypto.com",
						"sellRatio": 50.65
					},
					{
						"buyRatio": 32.49,
						"exchange": "BingX",
						"sellRatio": 67.51
					},
					{
						"buyRatio": 45.05,
						"exchange": "Bitget",
						"sellRatio": 54.95
					},
					{
						"buyRatio": 69.39,
						"exchange": "Deribit",
						"sellRatio": 30.61
					},
					{
						"buyRatio": 42.23,
						"exchange": "Bybit",
						"sellRatio": 57.77
					},
					{
						"buyRatio": 47.17,
						"exchange": "Bitmex",
						"sellRatio": 52.83
					},
					{
						"buyRatio": 49.54,
						"exchange": "Bitfinex",
						"sellRatio": 50.46
					},
					{
						"buyRatio": 37.56,
						"exchange": "CoinEx",
						"sellRatio": 62.44
					},
					{
						"buyRatio": 27.98,
						"exchange": "Kraken",
						"sellRatio": 72.02
					},
					{
						"buyRatio": 49.8,
						"exchange": "HTX",
						"sellRatio": 50.2
					},
					{
						"buyRatio": 49.94,
						"exchange": "Coinbase",
						"sellRatio": 50.06
					}
				],
				"optionsMarkets_ETH_30m": {
					"buyRatio": 42.82,
					"buyTimeEnd": "20:40",
					"buyTimeStart": "20:30",
					"coinType": "ETH",
					"price": "60727.06000000",
					"priceChangePercent": "0.4300",
					"range": "30m",
					"sellLossPercent": "40%",
					"sellProfitPercent": "20%",
					"sellRatio": 57.18,
					"sellTimeEnd": "20:50",
					"sellTimeStart": "20:40",
					"settlementLossPercent": "100%",
					"settlementProfitPercent": "75%",
					"settlementTimeEnd": "20:59:59",
					"settlementTimeStart": "20:50"
				}
			}
			// setInterval(e=>{
			// 	this.callBack(obj);
			// },1000)
			this.is_open_socket = true;
			clearInterval(this.heartbeatInterval);
			clearInterval(this.reconnectInterval);
			this.start();
			this.reconnect();
			// 监听消息
			this.socketTask.onMessage((res) => {
				// this.requestNum++;
				// console.log(res, 'websocket监听到的消息'+this.requestNum);
				clearInterval(this.reconnectInterval);
				this.reconnect();
				let obj = JSON.parse(res.data);
				// console.log(obj, 'websocket监听到的消息2');
				this.callBack(obj);
			});
		})
		// 连接失败
		uni.onSocketError((res) => {
			console.log('连接失败', res);
			this.is_open_socket = false;
			// this.connectSocketInit();
		});
		// socket关闭
		this.socketTask.onClose(() => {
			console.log("关闭了");
			if (this.isClose) {
				return
			};
			this.is_open_socket = false;
			this.connectSocketInit();
		})
	}

	//发送消息
	send(value) {
		this.socketTask.send({
			data: value,
			async success() {
				// console.log("消息发送成功");
			},
		});
	}
	//开启心跳检测
	start() {
		this.heartbeatInterval = setInterval(() => {
			// this.data = {
			// 	value: "ping",
			// 	type: "ping"
			// };
			this.send('haha');
		}, 5000)
	}
	//重新连接
	reconnect() {
		this.reconnectInterval = setInterval(res=> {
			this.is_open_socket = false;
			this.connectSocketInit();
		}, 6000)
	}
	//手动关闭链接
	closeWebsocket() {
		this.isClose = true;
		clearInterval(this.heartbeatInterval);
		clearInterval(this.reconnectInterval);
		this.socketTask.close({});
	}
}

module.exports = websocket;